<?php

class MusicModel extends SCModel {
	
	public function __construct() {
		parent::__construct();
	}
	
	
	/**
	 * 删除与指定thing关联的音乐记录及缩略图
	 * @param integer $thing_id
	 */
	public function dropMusicByThingId($thing_id) {
		$music = $this->from('sc_music')->where('thing_id = '.$thing_id)->findOne();
		if($music) {
			$upload_path = SCConfig::get('UPLOAD_PATH');
			@unlink($upload_path.'/'.$music->preview_path);
			
			$this->reset()->from('sc_music')->where('thing_id = '.$thing_id)->delete();
		}
	}
	
} 